/*创建一个类的格式：
class ClassName{
    field;//字段（属性）或者成员变量
    method;//行为或者成员方法
}
*/
//定义一个动物类
class Animal{
    public String name;
    public String color;
    public int age;
    public Animal(String myname,String mycolor,int myage){
        name=myname;
        age=myage;
        color=mycolor;
    }
    public void voice(){
        System.out.println(name+"正在叫");
    }
    public void eat(){
        System.out.println(name+"正在吃饭");
    }
    public void output(){
        System.out.println(name+"  "+color+"  "+age);
    }
}
class Dog extends Animal{
    public Dog(String myname,String mycolor,int myage){
        super(myname,mycolor,myage);
    }
    @Override
    public void voice(){
        System.out.println("Dog "+name+"正在汪汪叫");
    }
    @Override
    public void eat(){
        System.out.println("Dog "+name+"正在吃狗粮");
    }
    @Override
    public void output(){
        System.out.print("A dog ；");
        super.output();
    }
}
class Cat extends Animal{
    public Cat(String myname,String mycolor,int myage){
        super(myname,mycolor,myage);
    }
    @Override
    public void voice(){
        System.out.println("Cat "+name+"正在喵喵叫");
    }
    @Override
    public void eat(){
        System.out.println("Cat "+name+"正在吃猫粮");
    }
    @Override
    public void output(){
        System.out.print("A cat ；");
        super.output();
    }
}
public class Main {
    public static void main(String[] args) {
        //类的实例化
        /*1. 使用new关键字用于创建一个对象的实例
          2. 使用 . 来访问对象中的属性和方法
          3.同一个类可以创建多个实例
         */
        Dog a=new Dog("jenny","red",10);
        Dog b=new Dog("Danny","blue",12);
        Cat c=new Cat("Marry","brown",6);
        a.eat();
        a.voice();
        a.output();
        b.eat();
        b.voice();
        b.output();
        c.eat();
        c.voice();
        c.output();
    }
}